home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-15 / memtest2.zip / MEMTEST2.PRG < prev   
Text File  |  1993-01-04  |  16KB  |  679 lines

  1. *:*********************************************************************
  2. *:
  3. *:        Program: MEMTEST2.PRG
  4. *:
  5. *:         System: FoxBASE+ MEMORY VARIABLE MEMORY HANDLING
  6. *:         Author: Pat Adams
  7. *:      Copyright (c) 1989, DB Unlimited
  8. *:  Last modified: 02/03/89     17:32
  9. *:
  10. *:  Procs & Fncts: REGULAR1
  11. *:               : HIDE1
  12. *:               : PUBLIC1
  13. *:               : MIXUP1
  14. *:               : PPASS1
  15. *:               : PASMIX1
  16. *:               : REGULAR2
  17. *:               : HIDE2
  18. *:               : PUBLIC2
  19. *:               : PUBLIC3
  20. *:               : MIXUP2
  21. *:               : MIXUP3
  22. *:               : PPASS2
  23. *:               : PASMIX2
  24. *:
  25. *:          Calls: REGULAR1       (procedure in MEMTEST2.PRG)
  26. *:               : HIDE1          (procedure in MEMTEST2.PRG)
  27. *:               : PUBLIC1        (procedure in MEMTEST2.PRG)
  28. *:               : MIXUP1         (procedure in MEMTEST2.PRG)
  29. *:               : PPASS1         (procedure in MEMTEST2.PRG)
  30. *:               : PASMIX1        (procedure in MEMTEST2.PRG)
  31. *:
  32. *:      Documented 02/03/89 at 17:48                SNAP!  version 3.12e
  33. *:*********************************************************************
  34. * MEMTEST.PRG
  35. *
  36. *   This program tests handling of memory variables,
  37. *   arrays, parameter passing, and the RELEASE command.
  38. *
  39. *   Author: Pat Adams, DB Unlimited  1/20/89
  40. *
  41. * * * * * * * * * *
  42. *
  43. SET PROC TO memtest2
  44. CLEAR MEMORY
  45. SET TALK OFF
  46. SET BELL OFF
  47. SET COLOR TO GR+/N, W+/B
  48. SET STATUS ON
  49. * ======================
  50. * $ Do routine to show activity
  51. *   associated with the three
  52. *   categories of memory variables
  53. * ======================
  54. DO regular1
  55. CLEAR MEMORY
  56. DO hide1
  57. DO public1
  58. DO mixup1
  59. DO ppass1
  60. DO pasmix1
  61. CLOSE PROC
  62. RETURN
  63.  
  64.  
  65.  
  66. *!*******************************************
  67. *!
  68. *!      Procedure: REGULAR1
  69. *!
  70. *!      Called by: MEMTEST2.PRG                  
  71. *!
  72. *!          Calls: REGULAR2       (procedure in MEMTEST2.PRG)
  73. *!
  74. *!*******************************************
  75. PROCEDURE regular1
  76. *********************************
  77. *& Test handling of standard memory variables
  78. *
  79. STORE "Standard memvar initalized at level 1" TO reg1a
  80. STORE CTOD("01/01/01") TO reg1b
  81. STORE 11111.11 TO reg1c
  82. SET COLOR TO GR+/N BR+/B
  83. CLEAR
  84. ?
  85. ? "  Standard memory variables have been initalized at level 1 "
  86. ? "  The REG1D logical memvar was declared but no input stored."
  87. ? "  The logical memory variable is not acknowledged."
  88. ?
  89. WAIT
  90. ?
  91. DISPLAY MEMO
  92. WAIT
  93. DO regular2
  94. SET COLOR TO GR+/N BR+/B
  95. CLEAR
  96. ? "   Now back at level 1"
  97. ? "   Notice that, since the PRIVATE statement was not"
  98. ? "   used specifically in establishing the memvars of the"
  99. ? "   same name at the two different levels, the memory"
  100. ? "   variables at level 1 and level 2, which all had the"
  101. ? "   same name, were not differentiated and the memvars"
  102. ? "   at level 1 were changed by the level 2 input."
  103. ? "   The input for REG1D is now not available and REG1D is"
  104. ? "   still not acknowledged as initalized."
  105. ?
  106. WAIT
  107. ?
  108. CLEAR TYPEAHEAD
  109. DISPLAY MEMO
  110. WAIT
  111. RETURN
  112. * END Procedure Regular1
  113.  
  114.  
  115.  
  116. *!*********************************************
  117. *!
  118. *!      Procedure: REGULAR2
  119. *!
  120. *!      Called by: REGULAR1       (procedure in MEMTEST2.PRG)
  121. *!
  122. *!********************************************
  123. PROCEDURE regular2
  124. ********************************
  125. *& Test handling of standard memvars at level 2
  126. *
  127. SET COLOR TO BR+/N, GR+/B
  128. CLEAR
  129. STORE "STOREd at level 2" TO reg1a
  130. STORE CTOD("02/02/02") TO reg1b
  131. STORE 22222.22 TO reg1c
  132. STORE .T. TO reg1d
  133. ?
  134. ? "  Now at level 2.  Regular memory variables have been initalized at"
  135. ? "  level 2 with the same name as those initalized at level 1."
  136. ? "  Note that the memory variables originally acknowledged at level 1"
  137. ? "  are, here at level 2, incorrectly evaluated as level 1 memvars and"
  138. ? "  information STOREd at this level has changed those memory variables."
  139. ? "  Because a logical .T. was stored to REG1D at level two, it is"
  140. ? "  acknowledged here at level 2."
  141. ?
  142. WAIT
  143. ?
  144. CLEAR TYPEAHEAD
  145. DISPLAY MEMO
  146. WAIT
  147. RETURN
  148. * END Procedure Regular2
  149.  
  150.  
  151. *!*************************************************
  152. *!
  153. *!      Procedure: HIDE1
  154. *!
  155. *!      Called by: MEMTEST2.PRG                  
  156. *!
  157. *!          Calls: HIDE2          (procedure in MEMTEST2.PRG)
  158. *!
  159. *!**************************************************
  160. PROCEDURE hide1
  161. *********************************
  162. *& Testing PRIVATE hidden memory variables
  163. *
  164. PRIVATE priv1a, priv1b, priv1c, priv1d
  165. STORE "PRIV initalized at level 1" TO priv1a
  166. STORE 11111.11 TO priv1b
  167. STORE CTOD("01/01/01") TO priv1c
  168. SET COLOR TO W+/R, GR+/B
  169. CLEAR
  170. ?
  171. ? "  PRIVATE (hidden) memvars have been initalized at level 1"
  172. ? "  Notice that although a PRIV1D memvar was declared, info"
  173. ? "  was not stored to it, and it [improperly] does not appear"
  174. ? "  in the memory variable list."
  175. ?
  176. WAIT
  177. ?
  178. DISPLAY MEMO
  179. WAIT
  180. DO hide2
  181. SET COLOR TO W+/R, GR+/B
  182. CLEAR
  183. ?
  184. ? "  Now back at level 1.  Note the proper differential was"
  185. ? "  made at each level and the PRIVATE hidden memvars declared"
  186. ? "  at level one still have the original information.  However,"
  187. ? "  the logical memvar PRIV1D is still not acknowledged at level 1."
  188. ?
  189. WAIT
  190. ?
  191. DISPLAY MEMO
  192. WAIT
  193. RETURN
  194. * END Procedure Hide1
  195.  
  196.  
  197. *!***************************************************
  198. *!
  199. *!      Procedure: HIDE2
  200. *!
  201. *!      Called by: HIDE1          (procedure in MEMTEST2.PRG)
  202. *!
  203. *!****************************************************
  204. PROCEDURE hide2
  205. ******************************
  206. *& Test PRIVATE (hidden) memvars at level 2
  207. *
  208. *
  209. PRIVATE priv1a, priv1b, priv1c, priv1d
  210. STORE "PRIV initalized at level 2" TO priv1a
  211. STORE 22222.22 TO priv1b
  212. STORE CTOD("02/02/02") TO priv1c
  213. STORE .T. TO priv1d
  214. SET COLOR TO W+/B, GR+/R
  215. CLEAR
  216. ?
  217. ?
  218. ? "  PRIVATE (hidden) memvars have been initalized at level 2 with the"
  219. ? "  same name as those at level 1."
  220. ?
  221. WAIT
  222. ?
  223. DISPLAY MEMO
  224. WAIT
  225. RETURN
  226. * END Procedure Hide2
  227.  
  228.  
  229. *!**********************************************
  230. *!
  231. *!      Procedure: PUBLIC1
  232. *!
  233. *!      Called by: MEMTEST2.PRG                  
  234. *!
  235. *!          Calls: PUBLIC2        (procedure in MEMTEST2.PRG)
  236. *!               : PUBLIC3        (procedure in MEMTEST2.PRG)
  237. *!
  238. *!***********************************************
  239. PROCEDURE public1
  240. ****************************
  241. *& Test PUBLIC memvars
  242. *
  243. *
  244. CLEAR MEMORY
  245. SET COLOR TO B/G, G+/W
  246. CLEAR
  247. PUBLIC pub1a, pub1b, pub1c, pub1d
  248. STORE "Public declared at level 1" TO pub1a
  249. STORE 11111.11 TO pub1b
  250. STORE CTOD("01/01/01") TO pub1c
  251. ?
  252. ? "   Public memvars have been declared and initalized at level 1"
  253. ? "   Logical memvar PUB1D was declared PUBLIC but not initalized."
  254. ? "   Unlike the way PRIVATE acts, the PUB1D logical memvar is acknowledged."
  255. ?
  256. WAIT
  257. ?
  258. DISPLAY MEMO
  259. WAIT
  260. DO public2
  261. SET COLOR TO B/G, G+/W
  262. CLEAR
  263. ?
  264. ? "  We have now returned to level 1.  Notice that the PUBLIC memory"
  265. ? "  variables were properly updated by changes made at level 2"
  266. ?
  267. WAIT
  268. ?
  269. DISP MEMORY
  270. WAIT
  271. CLEAR MEMO
  272. SET COLOR TO B/G, G+/W
  273. PUBLIC pub1a, pub1b, pub1c, pub1d
  274. STORE "Public declared at level 1" TO pub1a
  275. STORE 11111.11 TO pub1b
  276. STORE CTOD("01/01/01") TO pub1c
  277. CLEAR
  278. ? "  Now we are going to test what happends when PUBLIC memvars of"
  279. ? "  the same name are declared at both level 1 and level 2"
  280. ? "  Memvars have been established at level 1, but the PUB1D memvar"
  281. ? "  has not had input."
  282. ?
  283. WAIT
  284. DISPLAY MEMO
  285. ?
  286. WAIT
  287. DO public3
  288. SET COLOR TO B/G, G+/W
  289. CLEAR
  290. ?
  291. ? "  We have now returned to level 1.  NOTE that although the"
  292. ? "  PUBLIC memvars were redeclared at level 2, no problems"
  293. ? "  resulted.  Data stored at level 2 is available at level 1."
  294. ?
  295. WAIT
  296. ?
  297. DISP MEMO
  298. WAIT
  299. RETURN
  300.  
  301.  
  302.  
  303.  
  304. *!********************************************
  305. *!
  306. *!      Procedure: PUBLIC2
  307. *!
  308. *!      Called by: PUBLIC1        (procedure in MEMTEST2.PRG)
  309. *!
  310. *!*********************************************
  311. PROCEDURE public2
  312. *****************************
  313. *& Test handling of public memvars at level 2
  314. *
  315. *
  316. STORE "Changed at level 2" TO pub1a
  317. STORE 22222.22 TO pub1b
  318. STORE CTOD("02/02/02") TO pub1c
  319. STORE .T. TO pub1d
  320. SET COLOR TO G+/GR, GR+/N
  321. CLEAR
  322. ?
  323. ? "  Now at level 2.  Contents of the public memvars have been changed"
  324. ?
  325. WAIT
  326. ?
  327. DISPLAY MEMORY
  328. WAIT
  329. RETURN
  330. * END Procedure Public2
  331.  
  332.  
  333. *!**********************************************
  334. *!
  335. *!      Procedure: PUBLIC3
  336. *!
  337. *!      Called by: PUBLIC1        (procedure in MEMTEST2.PRG)
  338. *!
  339. *!***********************************************
  340. PROCEDURE public3
  341. ******************************
  342. *& Test duplication of PUBLIC memvars
  343. PUBLIC pub1a, pub1b, pub1c, pub1d
  344. STORE "Public declared at level 2" TO pub1a
  345. STORE 22222.22 TO pub1b
  346. STORE CTOD("02/02/02") TO pub1c
  347. STORE .T. TO pub1d
  348. SET COLOR TO N/BR, B/GR
  349. CLEAR
  350. ?
  351. ? "  Now at level 2.  The entire set of memvars has been declared"
  352. ? "  PUBLIC again, using the same memvar names."
  353. ?
  354. WAIT
  355. ?
  356. DISPLAY MEMO
  357. WAIT
  358. RETURN
  359. * END Procedure Public3
  360.  
  361.  
  362. *!***************************************************
  363. *!
  364. *!      Procedure: MIXUP1
  365. *!
  366. *!      Called by: MEMTEST2.PRG                  
  367. *!
  368. *!          Calls: MIXUP2         (procedure in MEMTEST2.PRG)
  369. *!               : MIXUP3         (procedure in MEMTEST2.PRG)
  370. *!
  371. *!******************************************************
  372. PROCEDURE mixup1
  373. ***********************************
  374. *& Mix private and public memvars
  375. *
  376. CLEAR MEMO
  377. SET COLOR TO GR+/N, N/G
  378. CLEAR
  379. ?
  380. ? "  The next lines of code will generate an error message."
  381. ? "  Please respond with an I for ignore"
  382. ?
  383. WAIT
  384. ?
  385. PRIVATE mix1
  386. STORE "Level 1 initalization" TO mix1
  387. PUBLIC mix1
  388. STORE "Test PRIV & PUBLIC conflicts at 1" TO mix1
  389. SET COLOR TO GR+/N, N/G
  390. CLEAR
  391. ?
  392. ? " An attempt has been made to establish a PRIVATE and a PUBLIC"
  393. ? " memvar of the same name at level 1.  The PRIVATE mix1 memvar"
  394. ? " was declared first and takes precedence.  Note that PRIVATE "
  395. ? " and PUBLIC memvars of the same name are not permitted at "
  396. ? " the same level."
  397. ?
  398. WAIT
  399. DISP MEMO
  400. WAIT
  401. CLEAR MEMO
  402. PRIVATE mix2
  403. STORE "Level 1 mix & match test" TO mix2
  404. CLEAR
  405. ? "  This is another mix and match test of PUBLIC and PRIVATE."
  406. ? "  A PRIVATE memvar named MIX2 has been initalized at level 1."
  407. ?
  408. WAIT
  409. ?
  410. DISP MEMO
  411. WAIT
  412. DO mixup2
  413. CLEAR
  414. ?
  415. ? "  We have now returned to level 1 with the mixup test."
  416. ? "  We could not establish both a PRIVATE memvar here and a PUBLIC "
  417. ? "  memvar of the same name at a lower level.  However, FoxBASE+ did"
  418. ? "  not respond correctly because the character string for the"
  419. ? "  PRIVATE memvar declared at level 1 now contains the information we"
  420. ? "  attempted to place in the PUBLIC memvar at the lower level."
  421. ? "  Take a look at the value of the MIX2 memvar."
  422. ?
  423. WAIT
  424. ?
  425. DISP MEMO
  426. WAIT
  427. CLEAR MEMO
  428. PUBLIC mix3
  429. CLEAR
  430. STORE "PUB initalized at level 1" TO mix3
  431. ?
  432. ? "  Now we will test the ability to declare a PUBLIC memvar at one level"
  433. ? "  and then initalize a PRIVATE memvar of the same name at a lower level."
  434. ?
  435. WAIT
  436. ?
  437. DISPLAY MEMO
  438. WAIT
  439. DO mixup3
  440. CLEAR
  441. ?
  442. ? "   We have now returned to level in the PUBLIC and PRIVATE mix and match"
  443. ? "   test.  In this instance, FoxBASE+ has handled the situation correctly."
  444. ?
  445. WAIT
  446. ?
  447. DISPLAY MEMO
  448. ?
  449. WAIT
  450. * END Procedure Mixup1
  451.  
  452.  
  453.  
  454.  
  455. *!***************************************************
  456. *!
  457. *!      Procedure: MIXUP2
  458. *!
  459. *!      Called by: MIXUP1         (procedure in MEMTEST2.PRG)
  460. *!
  461. *!**************************************************
  462. PROCEDURE mixup2
  463. ******************************
  464. *& Mix & Match memvar test
  465. *
  466. CLEAR
  467. ?
  468. ? "  The next lines of code will generate an error message."
  469. ? "  Please input an I for ignore."
  470. ?
  471. WAIT
  472. PUBLIC mix2
  473. CLEAR
  474. STORE "Public memvar initalized at level 2" TO mix2
  475. CLEAR
  476. ?
  477. ? "  Again, it was not possible to create a PUBLIC memvar with the same"
  478. ? "  name as a PRIVATE memvar declared at the higher level."
  479. ?
  480. WAIT
  481. ?
  482. DISP MEMO
  483. WAIT
  484. RETURN
  485. * END Procedure Mixup2
  486.  
  487.  
  488. *!**********************************************
  489. *!
  490. *!      Procedure: MIXUP3
  491. *!
  492. *!      Called by: MIXUP1         (procedure in MEMTEST2.PRG)
  493. *!
  494. *!***********************************************
  495. PROCEDURE mixup3
  496. **********************************
  497. *& Test mixing of PUBLIC & Private memvars
  498. *
  499. CLEAR
  500. PRIVATE mix3
  501. STORE "PRIV initalized at level 2" TO mix3
  502. ?
  503. ? " Now at level 2.  FoxBASE+ has permitted us to initalize a PRIVATE"
  504. ? " memory variable with the same name as the PUBLIC memvar [MIX3]"
  505. ? " declared at the higher level."
  506. ?
  507. WAIT
  508. ?
  509. DISPLAY MEMO
  510. ?
  511. WAIT
  512. RETURN
  513. * END Procedure Mixup3
  514.  
  515. *!**************************************************
  516. *!
  517. *!      Procedure: PPASS1
  518. *!
  519. *!      Called by: MEMTEST2.PRG                  
  520. *!
  521. *!          Calls: PPASS2         (procedure in MEMTEST2.PRG)
  522. *!
  523. *!***************************************************
  524. PROCEDURE ppass1
  525. *********************************************
  526. *& Test parameter passing - Level 1
  527. *
  528. CLEAR MEMORY
  529. SET COLOR TO BG+/N, B/W
  530. CLEAR
  531. STORE "Level 1" TO cparam
  532. STORE 11111.11 TO nparam
  533. STORE .F. TO lparam
  534. ?
  535. ? "  We are now at level 1 of the test for passing of parameters."
  536. ? "  Memory variables have been initalized and will be passed to level 2"
  537. ?
  538. WAIT
  539. ?
  540. DISPLAY MEMO
  541. WAIT
  542. DO ppass2 WITH cparam, nparam, lparam
  543. CLEAR
  544. ?
  545. ? "  Now back at level 1 of parameter passing test.  Note that the"
  546. ? "  information in the memory variables that were passed down to"
  547. ? "  level still remain changed by the activity in level 2."
  548. ?
  549. WAIT
  550. ?
  551. DISPLAY MEMO
  552. ?
  553. WAIT
  554. RETURN
  555. * END Procedure PPASS1
  556.  
  557.  
  558.  
  559. *!*********************************************
  560. *!
  561. *!      Procedure: PPASS2
  562. *!
  563. *!      Called by: PPASS1         (procedure in MEMTEST2.PRG)
  564. *!
  565. *!**********************************************
  566. PROCEDURE ppass2
  567. ********************************
  568. *& Test of parameter passing
  569. *
  570. PARAMETERS xchar, xnum, xlogic
  571. CLEAR
  572. ? "   We are now at level 2 of the parameter passing test.  No actions"
  573. ? "   have yet been taken other than to pass down the parameters."
  574. ?
  575. WAIT
  576. ?
  577. DISPLAY MEMO
  578. ?
  579. WAIT
  580. STORE "Changed at level 2" TO xchar
  581. STORE 22222.22 TO xnum
  582. STORE .T. TO xlogic
  583. CLEAR
  584. ?
  585. ? "  New data has been stored to the passed parameters.  Take a look"
  586. ? "  at the effect on the original memory variables established at level 1."
  587. ? "  Instead of actually storing the input from level two to the 'passed'"
  588. ? "  memvars, the original memvars at level 1 have been changed.  This is"
  589. ? "  known as passing by reference."
  590. ?
  591. WAIT
  592. >
  593. DISPLAY MEMO
  594. ?
  595. WAIT
  596. RETURN
  597. * END Procedure PPASS2
  598.  
  599.  
  600. *!*********************************************
  601. *!
  602. *!      Procedure: PASMIX1
  603. *!
  604. *!      Called by: MEMTEST2.PRG                  
  605. *!
  606. *!          Calls: PASMIX2        (procedure in MEMTEST2.PRG)
  607. *!
  608. *!***********************************************
  609. PROCEDURE pasmix1
  610. *********************************
  611. *& Test passing of parameters and use of PRIVATE at level 2
  612. *
  613. CLEAR MEMORY
  614. PRIVATE cparam, napram, lparam
  615. STORE "Level 1" TO cparam
  616. STORE 11111.11 TO nparam
  617. STORE .F. TO lparam
  618. SET COLOR TO R+/N, W+/R
  619. CLEAR
  620. ?
  621. ? "  Now we will test passing of parameters where the memory variables"
  622. ? "  passed have first been declared private at level 1."
  623. ?
  624. WAIT
  625. ?
  626. DISPLAY MEMO
  627. ?
  628. WAIT
  629. DO pasmix2 WITH cparam, nparam, lparam
  630. CLEAR
  631. ?
  632. ? "  Now we have returned to level 1.  Let's see if the original memvars"
  633. ? "  have been changed."
  634. ?
  635. WAIT
  636. ?
  637. DISPLAY MEMO
  638. ?
  639. WAIT
  640. RETURN
  641. * END Procedure Pasmix1
  642.  
  643.  
  644.  
  645.  
  646. *!******************************************
  647. *!
  648. *!      Procedure: PASMIX2
  649. *!
  650. *!      Called by: PASMIX1        (procedure in MEMTEST2.PRG)
  651. *!
  652. *!*******************************************
  653. PROCEDURE pasmix2
  654. ****************************************
  655. PARAMETERS xchar, xnum, xlogic
  656. CLEAR
  657. ? "  Now at level 2.  No action has been taken other than to pass down"
  658. ? "  the parameters from level 1."
  659. ?
  660. WAIT
  661. ?
  662. DISPLAY MEMO
  663. ?
  664. WAIT
  665. STORE "Changed at level 2" TO xchar
  666. STORE 22222.22 TO xnum
  667. STORE .T. TO xlogic
  668. CLEAR
  669. ?
  670. ? "  Changes have now been made to the memvar/parameters at level 2."
  671. ?
  672. WAIT
  673. ?
  674. DISPLAY MEMO
  675. ?
  676. WAIT
  677. RETURN
  678. * END Procedure Pasmix2
  679.